﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Recaptcha;
using System.Configuration;
using System.Web.UI;
using System.IO;

namespace mBlog.Helpers
{
    public static class RecaptchaHelperExtensions
    {
        public static MvcHtmlString GenerateCaptcha(this HtmlHelper helper)
        {
            var control = new RecaptchaControl
            {
                ID = "recaptcha",
                Theme = "clean",
                PublicKey = ConfigurationManager.AppSettings["ReCaptchaPublicKey"],
                PrivateKey = ConfigurationManager.AppSettings["ReCaptchaPrivateKey"]
            };
            var writer = new HtmlTextWriter(new StringWriter());
            control.RenderControl(writer);
            var html = writer.InnerWriter.ToString();
            return MvcHtmlString.Create(html);
        }
    }
}